#include "StompedReality/Core/MessageSystem/Message.h"
namespace StompedReality
{
namespace Core
{
Message::Message ( const char messageType, ID senderID, TYPE_ID senderType, int dataSize )
  : StompedReality::Core::DataBuffer ( dataSize + sizeof(char) + sizeof ( unsigned ) * 2 )
{
  this->m_IterPos = 0;
  this->m_length = dataSize + 1 + sizeof ( unsigned ) * 2;
  this->SetValue<char> ( 0, messageType );
  this->SetValue<unsigned> ( sizeof(char), senderID );
  this->SetValue<unsigned> ( sizeof(char) + sizeof(unsigned), senderType );
}

Message::~Message( )
{
}

const char Message::GetMessageType( )
{
  return this->GetValue<char> ( 0 );
}

void Message::ChangeMessageType ( const char messageType )
{
  this->SetValue<char> ( 0, messageType );
}

const unsigned Message::GetSenderID( )
{
  return this->GetValue<unsigned> ( sizeof(char) );
}

const unsigned Message::GetSenderType( )
{
  return this->GetValue<unsigned> ( sizeof(char) + sizeof(unsigned) );
}

void Message::BeginIteration( )
{
  this->m_IterPos = sizeof(char) + sizeof(unsigned) * 2;
}

bool Message::HasMore( )
{
  return this->m_IterPos < this->m_length;
}

}
}
